<template>
	<view>
		<view class="risk-tab-top">
			<view class="risk-tab-cont" @click="tabChange(index)" v-for="(item,index) in tabList " :class="[active == index?'risk-active':'']"
			 :key="index">{{item}}</view>
			<view class="risk-active-line" :class="[active == 0?'risk-active-line-f':'risk-active-line-r']"></view>
		</view>
		<view class="risk-cont">
			<Rule :active="active"></Rule>
			<ProductDetails :active="active"></ProductDetails>
		</view>
	</view>
</template>

<script>
	import Rule from "@/components/groupbuy/rule.vue"
	import ProductDetails from "@/components/groupbuy/product-details.vue"
	export default {
		components: {
			Rule,
			ProductDetails
		},
		data() {
			return {
				tabList: ['拼团规则', '商品详情'],
				active: 0
			};
		},
		methods: {
			tabChange(val) {
				this.active = val;
				console.log(val);
			}
		}
	}
</script>

<style lang="scss">
	.risk-tab-top {
		color: #2A2A2A;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding: 41rpx 0 12rpx 0;
		background-color: #FFFFFF;
		position: relative;
		border-bottom: 1rpx solid #E6E6E6;

		.risk-tab-cont {
			cursor: pointer;
			width: 50%;
			text-align: center;
			font-size: 30rpx;

		}

		.risk-active {
			color: #2A2A2A;
			font-weight: bold;
			font-size: 30rpx;
			font-family: PingFang;
			font-weight: bold;
		}

		.risk-active-line {
			width: 64rpx;
			height: 5rpx;
			background: #FFC933;
			position: absolute;
			bottom: 0;
			transition: all 0.3s ease;
		}

		.risk-active-line-f {
			left: 21%;
		}

		.risk-active-line-r {
			left: 71%;
		}
	}

	.risk-cont {
		width: 100%;
		height: 100%;
		background-color: #FFFFFF;
	}
</style>
